
<!--header-->
<!-- 引用头部 -->
{include file="common/top"}

<!-- 引入左侧 -->
{include file="common/left"}

<section class="rt_wrap content mCustomScrollbar">
<div class="rt_content">
	<section>
      <h2><strong style="color:grey;">产品展示列表</strong></h2>
      <div class="page_title">
       <h2 class="fl">例如产品详情标题</h2>
       <a href="{:url('product/addProduct')}" class="fr top_rt_btn">添加新产品</a>
       <a href="{:url('product/listProduct')}" class="fr top_rt_btn">产品列表</a>
      </div>
      <table class="table">
      	<tr>
        <th>产品名称</th>
        <th>产品添加人</th>
        <th>产品总金额</th>
        <th>产品介绍</th>
        <th>审核状态</th>
        <th>开始时间</th>
        <th>结束时间</th>
       </tr>
       <?php foreach($productList as $v){?>
       <tr>
        <td><?= $v['productName']?></td>
        <td><?= $v['adminUserName']?></td>
        <td><?= $v['totalSum']?></td>
        <td><?= $v['introduce']?></td>
        <td><?= $v['status'];?></td>
        <td><?= $v['startTime']?></td>
        <td><?= $v['endTime']?></td>
       </tr>
       <?php }?>
      </table>
      <aside class="paging">
        <a href="javascript:void(0)" class="first" id="btn">首页</a>
        <a href="javascript:void(0)" class="perv" id="btn">上一页</a>
		<a href="javascript:void(0)" class="next" id="btn">下一页</a>
		<a href="javascript:void(0)" class="last" id="btn">尾页</a>
		<input type="hidden" value="1" class="page">
		<input type="hidden" value="<?php echo $last;?>" id="last">
      </aside>
     </section>
</div>

<script type="text/javascript">
	//分页
	$(document).on('click','#btn',function()
	{
		var pagenew = parseInt($('.page').val());

		var last = $('#last').val();

		if($(this).is('.first'))
		{
			var p = 1;
		}
		if($(this).is('.perv'))
		{
			var p = pagenew-1;
		}
		if($(this).is('.next'))
		{
			var p = pagenew+1;
		}
		if($(this).is('.last'))
		{
			var p = last;
		}
		if(p<1 || p>last)
		{
			return false;
		}
		if((p==1 && p==pagenew)||(p==last && pagenew==last))
		{
			return false;
		}
		$.ajax({
			url:"{:url('product/listProduct')}",
			type:"post",
			data:{p:p},
			dataType:"json",
			success:function(result)
			{
				if(result.error == 0)
				{
					str = "<tr><th>产品名称</th><th>产品添加人</th><th>产品总金额</th><th>产品介绍</th><th>审核状态</th><th>开始时间</th><th>结束时间</th></tr>";
					for(var i=0;i<result.data.length;i++)
					{
						str+="<tr>\
        <td>"+result.data[i].productName+"</td>\
        <td>"+result.data[i].adminUserName+"</td>\
        <td>"+result.data[i].totalSum+"</td>\
        <td>"+result.data[i].introduce+"</td>\
        <td>"+result.data[i].status+"</td>\
        <td>"+result.data[i].startTime+"</td>\
        <td>"+result.data[i].endTime+"</td>\
       </tr>";
					}
					$('table').html(str);
					$('.page').val(p);
				}
			}
		})
	})
</script>